<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org">
<head>
    <th:block th:include="include :: header('新增活动')"/>
    <th:block th:include="include :: datetimepicker-css"/>
    <th:block th:include="include :: bootstrap-fileinput-css"/>
    <th:block th:include="include :: summernote-css"/>
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-activity-add">
        <input name="adminId" class="form-control" type="hidden" th:value="${user.userId}"/>

        <!--<div class="form-group">
            <label class="col-sm-3 control-label">区域ID：</label>
            <div class="col-sm-8">
                <input name="areaId" class="form-control" type="text">
            </div>
        </div>-->
        <div class="form-group">
            <label class="col-sm-3 control-label">活动标题：</label>
            <div class="col-sm-8">
                <input name="title" class="form-control"></input>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">活动简介：</label>
            <div class="col-sm-8">
                <input name="brief" class="form-control"></input>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">开始时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="startTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">结束时间：</label>
            <div class="col-sm-8">
                <div class="input-group date">
                    <span class="input-group-addon"><i class="fa fa-calendar"></i></span>
                    <input name="endTime" class="form-control" placeholder="yyyy-MM-dd" type="text">
                </div>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">活动栏目：</label>
            <div class="col-sm-8">
                <select name="category" class="form-control m-b">
                    <option selected="selected" th:value="${menu.menuId}" th:text="${menu.menuName}"></option>
                </select>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">报名人数：</label>
                <div class="col-sm-8">
                    <input name="personLimit" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联络人：</label>
                <div class="col-sm-8">
                    <input name="contacter" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">活动地址：</label>
                <div class="col-sm-8">
                    <textarea name="address" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">联系电话：</label>
                <div class="col-sm-8">
                    <input name="phone" class="form-control" type="text">
                </div>
            </div>

            <div class="form-group">
                <label class="col-sm-3 control-label">活动海报：</label>
                <div class="col-sm-8">
                    <div class="file-loading">
                        <input id="filePath" class="file" type="file" multiple data-min-file-count="1" data-theme="fas">
                    </div>
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">活动内容：</label>
                <div class="col-sm-8">
                    <div class="ibox-content no-padding">
                    <textarea name="photos" class="summernote">
                    </textarea>
                    </div>
                </div>
            </div>
            <!--<div class="form-group">
                <label class="col-sm-3 control-label">0普通类型：</label>
                <div class="col-sm-8">
                    <input name="tpe" class="form-control" type="text">
                </div>
            </div>-->

            <!--  <div class="form-group">
                 <label class="col-sm-3 control-label">现场签到审核人员：</label>
                 <div class="col-sm-8">
                     <input name="mid" class="form-control" type="text">
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-3 control-label">发起支部：</label>
                 <div class="col-sm-8">
                     <input name="groupName" class="form-control" type="text">
                 </div>
             </div>
            <div class="form-group">
                 <label class="col-sm-3 control-label">发起人：</label>
                 <div class="col-sm-8">
                     <input name="addName" class="form-control" type="text">
                 </div>
             </div>
             <div class="form-group">
                 <label class="col-sm-3 control-label">奖励规则ID：</label>
                 <div class="col-sm-8">
                     <input name="eventCode" class="form-control" type="text">
                 </div>
             </div>-->
            <<!--div class="form-group">
                <label class="col-sm-3 control-label">图集：</label>
                <div class="col-sm-8">
                    <textarea name="photos" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">是否已通知：</label>
                <div class="col-sm-8">
                    <input name="isNotify" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">
                <label class="col-sm-3 control-label">关联新闻的ID：</label>
                <div class="col-sm-8">
                    <textarea name="newsids" class="form-control"></textarea>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">点击数：</label>
                <div class="col-sm-8">
                    <input name="clickCount" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">点赞数：</label>
                <div class="col-sm-8">
                    <input name="likes" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">0未上报，1已上报：</label>
                <div class="col-sm-8">
                    <input name="isReport" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">0 未审，1通过，2不通过：</label>
                <div class="col-sm-8">
                    <div class="radio-box" th:each="dict : ${@dict.getType('sys_check_status')}">
                        <input type="radio" th:id="${'isCheck_' + dict.dictCode}" name="isCheck" th:value="${dict.dictValue}" th:checked="${dict.default}">
                        <label th:for="${'isCheck_' + dict.dictCode}" th:text="${dict.dictLabel}"></label>
                    </div>
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">不通过原因：</label>
                <div class="col-sm-8">
                    <input name="checkCase" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">0 未审，1通过，2不通过：</label>
                <div class="col-sm-8">
                    <input name="checkTime" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">审核人：</label>
                <div class="col-sm-8">
                    <input name="checkUser" class="form-control" type="text">
                </div>
            </div>
            <div class="form-group">    
                <label class="col-sm-3 control-label">参与人数：</label>
                <div class="col-sm-8">
                    <input name="joincount" class="form-control" type="text">
                </div>
            </div>-->
    </form>
</div>
<th:block th:include="include :: footer"/>
<th:block th:include="include :: datetimepicker-js"/>
<th:block th:include="include :: bootstrap-fileinput-js"/>
<th:block th:include="include :: summernote-js"/>
<script type="text/javascript">
    $(function () {
        $("#multiFile").fileinput({
            'theme': 'explorer-fas',
            'uploadUrl': '#',
            overwriteInitial: false,
            initialPreviewAsData: true
        });
        $('.summernote').summernote({
            lang: 'zh-CN'
        });
    });

    var prefix = ctx + "activity/activity"
    $("#form-activity-add").validate({
        focusCleanup: true
    });

    function submitHandler() {
        //文件上传
        var form = $("#form-activity-add")[0];
        var formData = new FormData(form);
        /*formData.append('file', files[0]);*/
        if ($('#filePath')[0].files[0] == null) {
            $.modal.alertWarning("请先选择文件路径");
            return false;
        }
        formData.append('file', $('#filePath')[0].files[0]);
        /*  var files = $('#multiFile')[0].files;
          if (files.length > 0) {
              for (var i = 0; i < files.length; i++) {
                  formData.append('multiFile', files[i]);
              }
          }*/
        /* var url = prefix + "/add";
         var data = {"formData": formData};
         $.operate.submit(url, "post", "json", data);*/
        $.ajax({
            url: prefix + "/add",
            type: 'post',
            cache: false,
            data: formData,
            processData: false,
            contentType: false,
            dataType: "json",
            success: function (result) {
                console.log(result)
                setTimeout(function () {
                    $.modal.close();
                }, 300);
                var parent = window.parent;
                parent.$.modal.msgSuccess("操作成功!");
                parent.$.table.refresh();
            }
        });
    };

    $("input[name='publishTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='startTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='endTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });

    $("input[name='addTime']").datetimepicker({
        format: "yyyy-mm-dd",
        minView: "month",
        autoclose: true
    });
</script>
</body>
</html>